/**
 * [153] 寻找旋转排序数组中的最小值
 *
 * @format
 * @lc app=leetcode.cn id=153 lang=javascript
 */

// @lc code=start
/**
 * @param {number[]} nums
 * @return {number}
 */
// 二分法
var findMin = function (nums) {
    const N = nums.length
    let [left, right, mid] = [0, N - 1, Math.floor(N / 2)]
    while (right - left > 1) {
        nums[mid] > nums[N - 1] ? (left = mid) : (right = mid)
        mid = Math.floor((left + right) / 2)
    }
    return Math.min(nums[left], nums[right])
}
// debugger
// const nums = [3, 4, 5, 1, 2]
// const MIN = findMin(nums)
// console.log(MIN)
// @lc code=end
